package com.yoki.cloud.common.code.generator.impl;

import com.yoki.cloud.common.code.generator.AbstractCodeGenerator;
import freemarker.template.Configuration;

import java.io.*;
import java.util.*;

/**
 * @author kissy
 * @Description: 后端代码生成器
 * @date 2017/10/24 下午4:38
 */
public class ReactProCodeGenerator extends AbstractCodeGenerator {

    /**
     * 保存文件路径
     */
    private static final String SAVE_PATH_PRE = "C:\\Users\\SKY\\Desktop\\code\\yoki-cloud-bg-h5-shop\\";
    /**
     * 基础包名
     */
    private static final String BASE_PACKAGE = "com.yoki.cloud.bg.shop";
    /**
     * 模块名，分包用
     */
//    private static final String MODULE_NAME = "vp";

    @Override
    public String getBasePackage() {
        return BASE_PACKAGE;
    }

//    @Override
//    public String getModuleName() {
//        return MODULE_NAME;
//    }

    @Override
    public String getSavePathPre() {
        return SAVE_PATH_PRE;
    }

    @Override
    public String getFtlRelativePath() {
        return "react_pro";
    }

    public static void main(String[] args) {
        ReactProCodeGenerator generator = new ReactProCodeGenerator();
        generator.generate();
    }

    @Override
    protected void genFiles(Map beanMap, Configuration cfg) throws IOException {
        genFile(beanMap, cfg, "model.ftl", ".js");
        genFile(beanMap, cfg, "pages.ftl", "Page.js");
        genFile(beanMap, cfg, "list.ftl", "List.js");
        genFile(beanMap, cfg, "add.ftl", "CreateForm.js");
        genFile(beanMap, cfg, "edit.ftl", "EditForm.js");
        genFile(beanMap, cfg, "service.ftl", "Service.js");
    }
}
